﻿@model List<Doan.Website.Models.Cancer> 
@using Ext.Net
@using Ext.Net.MVC
@{
    ViewBag.Title = "Danh sách bệnh ung thư";
    Layout = "~/Views/Shared/_Layout_Admin.cshtml";
}

@section Header
{
    <script type="text/javascript">
        function deleteItem(id) {
            var bt = confirm('Bạn có chắc chắn xóa đối tượng này?');
            if (bt == true) {
                App.direct.DeleteCancer(id);
            }
        }
    </script>
}
@section ToolbarSection{
    @Html.X().Button().Text("Tạo mới").Icon(Icon.ControlAddBlue).Listeners(ls => ls.Click.Handler = "showWindow('Create Cancer','/Cancer/CreateCancer',true ,1 ,1);")
}
@* GridPanel *@

@(Html.X().GridPanel().ID("DataGridPanelCancer")
        .Title("List Cancer")
        .Icon(Icon.Table)
        .Frame(true)
        .TopBar(Html.X().Toolbar().ID("ToolID").Items(items =>
         {
             items.Add(new LinkButton { Text = "All", Handler = "#{DirectMethods}.CharFilterCancer('');", });

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "0-9", Handler = "#{DirectMethods}.CharFilterCancer('0');", });

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "A", Handler = "#{DirectMethods}.CharFilterCancer('A');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "B", Handler = "#{DirectMethods}.CharFilterCancer('B');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "C", Handler = "#{DirectMethods}.CharFilterCancer('C');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "D", Handler = "#{DirectMethods}.CharFilterCancer('D');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "E", Handler = "#{DirectMethods}.CharFilterCancer('E');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "F", Handler = "#{DirectMethods}.CharFilterCancer('F');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "G", Handler = "#{DirectMethods}.CharFilterCancer('G');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "H", Handler = "#{DirectMethods}.CharFilterCancer('H');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "I", Handler = "#{DirectMethods}.CharFilterCancer('I');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "J", Handler = "#{DirectMethods}.CharFilterCancer('J');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "K", Handler = "#{DirectMethods}.CharFilterCancer('K');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "L", Handler = "#{DirectMethods}.CharFilterCancer('L');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "M", Handler = "#{DirectMethods}.CharFilterCancer('M');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "N", Handler = "#{DirectMethods}.CharFilterCancer('N');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "O", Handler = "#{DirectMethods}.CharFilterCancer('O');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "P", Handler = "#{DirectMethods}.CharFilterCancer('P');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "Q", Handler = "#{DirectMethods}.CharFilterCancer('Q');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "R", Handler = "#{DirectMethods}.CharFilterCancer('R');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "S", Handler = "#{DirectMethods}.CharFilterCancer('S');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "T", Handler = "#{DirectMethods}.CharFilterCancer('T');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "U", Handler = "#{DirectMethods}.CharFilterCancer('U');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "V", Handler = "#{DirectMethods}.CharFilterCancer('V');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "W", Handler = "#{DirectMethods}.CharFilterCancer('W');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "X", Handler = "#{DirectMethods}.CharFilterCancer('X');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "Y", Handler = "#{DirectMethods}.CharFilterCancer('Y');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "Z", Handler = "#{DirectMethods}.CharFilterCancer('Z');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarFill());
             
             items.Add(new Checkbox
             {
                 FieldLabel = "Gồm cả bản ghi đã xóa",
                 Margins = "0 0 0 10",
                 LabelWidth = 230,
                 DirectCheckAction = "IncludeInActive"
             });
         }))

        .Store(Html.X().Store().ID("CancerStore")
            .Model(Html.X().Model().IDProperty("CancerId")
                .Fields(
                    new ModelField("CancerId", ModelFieldType.Int),
                    new ModelField("CancerName", ModelFieldType.String),
                    new ModelField("Active", ModelFieldType.Boolean)
                )
            )
                .RemoteSort(true)
                .RemotePaging(true)
                .PageSize(15)
                    .Proxy(Html.X().AjaxProxy().Url(Url.Action("BindingCancerStore"))
                                .Reader(Html.X().JsonReader().Root("data")))
        )
        .ColumnModel(
                    Html.X().Column().Text("Tên bệnh").DataIndex("CancerName").Flex(1),
                    Html.X().Column().Text("Trạng thái kích hoạt").DataIndex("Active").Flex(1),
                    Html.X().CommandColumn().Width(60).Commands(Html.X().GridCommand().CommandName("Edit").Icon(Icon.NoteEdit).Text("Sửa"))
                        .Listeners(ls => ls.Command.Handler = "showWindow('Edit Cancer', '/Cancer/EditCancer/' + record.data.CancerId, true, 1, 1);"),
                    Html.X().CommandColumn().Width(60).Commands(Html.X().GridCommand().CommandName("Edit").Icon(Icon.Delete).Text("Xóa"))
                            .Listeners(ls => ls.Command.Handler = "deleteItem(record.data.CancerId);")
        )
        .SelectionModel(Html.X().CheckboxSelectionModel().RowSpan(1))
        .BottomBar(Html.X().PagingToolbar())
)
